/*
 * @描述: 全宗管理中抽取部分方法ts文件
 * @作者: 研发中心
 * @Date: 2019-12-06 15:02:32
 */
import vueAxios from "@/api/index";
import global from "@/utils/SnowflakeClass";

/**
 * @名字:getFondsList
 * @详情:获取全宗数据
 * @参数: 无
 * @返回值: 无
 */
export const getFondsList = (): Promise<any[]> => {
  return new Promise((resolve, reject) => {
    vueAxios.get("MasterBaseFonds/GetFondsTree").then((res: any) => {
      resolve(res.List);
    });
  });
};

/**
 * @名字:getClassID
 * @详情:获取关联门类id
 * @参数: 无
 * @返回值: 无
 */
export const getClassID = (Fonds_ID: string): Promise<any> => {
  const param = { order: "FC_ID asc", dtoList: [{ fieldName: "Fonds_ID", fieldValue: Fonds_ID, conditionalType: 0 }] };
  return new Promise((resolve, reject) => {
    vueAxios.post("Master_Base_Fonds_Class/GetConditional", param, { noLoading: true }).then(res => {
      resolve(res);
    });
  });
};
/**
 * @名字:getClassList
 * @详情:获取关联门类数据
 * @参数: 无
 * @返回值: 无
 */
export const getClassList = async (Fonds_ID: string): Promise<any> => {
  const res = await getClassID(Fonds_ID);
  const param = {
    order: "Class_Order asc",
    dtoList: [{ fieldName: "Class_ID", fieldValue: res.List.map((v: any) => v.Class_ID).join(","), conditionalType: 6 }]
  };
  return new Promise((resolve, reject) => {
    vueAxios.post("Master_Base_Class/GetConditional", param).then(res => {
      resolve(res);
    });
  });
};
